<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function foo(obj) {
            with (obj) {
                a = 2
            }
        }
        var o1 = {
            a: 3
        }
        var o2 = {
            b: 3
        }
        foo(o1)
        console.log(o1.a); // 2
        foo(o2)
        console.log(o2.a); // undefined
        console.log(a); // 2 发生了变量泄露到了全局作用域
    </script>
</body>

</html>